import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class GoodsRecommendPartsService {

  serviceUrls: any = {
    queryPartsClassifyUrl: '/goodstypes/list/', // 查询商品分类List
    queryPartsBrandUrl: '/brand/list', // 查询品牌分类List
    queryGoodsListUrl: '/recommendGoods/goodsList', // 查询商品列表List

    queryPartsRecommendGoodsUrl: '/recommendGoods/list', // 查询配件推荐商品List
    saveRecommendUrl: '/recommendGoods/update', // 新增编辑
  };

  constructor(public httpClient: HttpClient) {}

  // 查询商品分类List
  getPartsClassifyData() {
    return this.httpClient.get(`${this.serviceUrls.queryPartsClassifyUrl}1`).toPromise();
  }

  // 查询品牌分类List
  getPartsBrandData() {
    return this.httpClient.get(this.serviceUrls.queryPartsBrandUrl).toPromise();
  }

  // 查询品牌分类List
  getGoodsListData(params: any) {
    return this.httpClient.get(this.serviceUrls.queryGoodsListUrl, {params}).toPromise();
  }

  // 查询配件推荐商品List
  getPartsRecommendGoodsData(params: any) {
    return this.httpClient.get(this.serviceUrls.queryPartsRecommendGoodsUrl, {params}).toPromise();
  }

  // 保存推荐
  saveRecommendData(params: any) {
    return this.httpClient.post(this.serviceUrls.saveRecommendUrl, params).toPromise();
  }
}



